package ioc;

//建造汽车
class Car {
    private Framework framework;
    public Car(Framework framework) {
        this.framework = framework;
    }
    public void init() {
        System.out.println("初始化了Car");
        framework.init();
    }
}

//建造框架
class Framework {
    private Bottom bottom;
    public Framework(Bottom bottom) {
        this.bottom = bottom;
    }
    public void init() {
        System.out.println("初始化了Framework");
        bottom.init();
    }
}

//建造地盘
class Bottom {
    private Tire tire;
    public Bottom(Tire tire) {
        this.tire = tire;
    }
    public void init() {
        System.out.println("初始化了Bottom");
        tire.init();
    }
}

//建造轮胎
class Tire {
    private int size;
    public Tire(int size) {
        this.size = size;
    }
    public void init() {
        System.out.println("初始化了Tire, 轮胎尺寸是:" + size);
    }
}

public class Application {
    public static void main(String[] args) {
        Tire tire = new Tire(20);
        Bottom bottom = new Bottom(tire);
        Framework framework = new Framework(bottom);
        Car car = new Car(framework);
        car.init();
    }
}
